package com.itheima02;

import com.domain.Student;

import java.util.ArrayList;

/**
 * @author Xiao
 * @date 2021/7/6
 */
public class Print_ArrayList02 {
    /**
     * 集合存储学生对象并遍历
     * 创建一个存储学生对象的集合，存储3个学生对象
     * 使用程序实现在控制台遍历该集合
     */
    public static void main(String[] args) {
        Student stu1 = new Student("阿良", 24);
        Student stu2 = new Student("左右", 25);
        Student stu3 = new Student("平安", 21);
        System.out.println("----------------");
        ArrayList<Student> list = new ArrayList<>();
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println(stu.getName() + "\t" + stu.getAge());
        }
    }
}
